<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div id="app">
  <c></c>
</div>

<template id="cpn">
  <div>
    <h1>我是cpn组件</h1>
    <cc></cc>
  </div>
</template>

<template id="ccpn">
  <div>
    <h1>我是ccpn组件</h1>
    <button @click="btnClick">按钮</button>
  </div>
</template>

<script src="../js/vue.js"></script>
<script>
  //let(变量)和const(常量)
  const app = new Vue({
    el: '#app',
    data: {
      message: '中国牛蛙！'
    },
    methods: {
      showMessage() {
        console.log('--------showMessage---------')
      }
    },
    components: {
      c: {
        template: `#cpn`,
        components: {
          cc: {
            template: `#ccpn`,
            methods: {
              btnClick() {
                console.log(this.$root);
                this.$root.showMessage();
              }
            }
          }
        }
      }
    }
  })
</script>
</body>
</html>